<template>
  <div class="app-container">
    <div v-if="user">
      <el-row :gutter="20">
        <el-col :span="8" :xs="24">
          <user-card :user="user" />
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import UserCard from './components/UserCard'

export default {
  name: 'Profile',
  components: { UserCard },
  data() {
    return {
      user: {},
      activeTab: 'activity'
    }
  },
  computed: {
    ...mapGetters([ //store是全局变量，从store中获取用户数据
      'yhbh',
      'yhxm',
      'yhgs',
      'yhgroup',
      'roles' //roles即为操作权限
    ])
  },
  created() {
    this.getUser()
  },
  methods: {
    getUser() {
      this.user = { //设置用户信息
        yhbh: this.yhbh,
        yhxm: this.yhxm,
        yhgs: this.yhgs,
        yhgroup:this.yhgroup,
        role: this.roles.join(' | '),
        //avatar: this.avatar
      }
      console.log(this.user)
    }
  }
}
</script>